from selenium.webdriver.common.by import By
import time
from wordpress_project.base.base_page import Tools

class register_tools(Tools):
    register_url = "http://192.168.0.125:9009/wp-login.php?action=register"
    username_ele = '[id="user_login"]' # 用户名css定位
    useremail_ele = '[name="user_email"]' # 用户电子邮件 css 定位
    register_button_ele = '[name="wp-submit"]' # 注册按钮 css定位
    register_success_ele = '[id="login"]'  # 注册成功 之后的断言定位
    register_fail_ele = '[id="login_error"]'  # 登录失败 之后的 断言定位

    def register_action(self,usr,email):
        self.visit(self.register_url)
        self.by_css(self.username_ele).send_keys(usr)
        time.sleep(0.5)
        self.by_css(self.useremail_ele).send_keys(email)
        time.sleep(0.5)
        self.by_css(self.register_button_ele).click()
        time.sleep(0.5)



    def get_success_reg(reg_self):
        return reg_self.by_css(reg_self.register_success_ele).text

    def get_fail_reg(reg_self):
        return reg_self.by_css(reg_self.register_fail_ele).text
# from selenium import webdriver
# d = webdriver.Chrome()
# a = register_tools(driver=d)
# a.register_action(usr='qwe123', email='qwe123@nmsl.com')
# time.sleep(2)